clc; clear; close all;
% 不同初始条件 z0 下，变量 x 与 z 的相轨迹

% 参数设置
mu = 3.5;
k = 0.25;
x_init = 0.1;
y_init = 0;
z0_list = [ -1 - 2*pi,  -1,  -1 + 2*pi ];  % 三个 z0，彼此相差 2π

% 迭代步数
N_transient = 500;   % 去除瞬态
N_plot = 50000;       % 用于绘图

% 颜色与标记
color_list = {'b','k','r'};  

figure; hold on;
for idx = 1:length(z0_list)
    state = [x_init, y_init, z0_list(idx)];
    
    % --- 1. 瞬态迭代 ---
    for n = 1:N_transient
        [dx, dy, dz] = mclm(state, mu, k);
        state = [dx, dy, dz];
    end
    
    % --- 2. 正式迭代并记录 (x,z) ---
    xvals = zeros(1,N_plot);
    zvals = zeros(1,N_plot);
    for n = 1:N_plot
        [dx, dy, dz] = mclm(state, mu, k);
        state = [dx, dy, dz];
        xvals(n) = dx;
        zvals(n) = dz;
    end
    

    plot(xvals, zvals, '.', 'Color', color_list{idx});
end

xlabel('x'); 
ylabel('z');
title('不同 z_0 下的 x-z 相轨迹');

